Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for STS Regional Endpoint (#118) #119

Merged
merged 5 commits into from
Jul 7, 2023

Conversation

menuetb
Copy link
Contributor

@menuetb menuetb commented Apr 27, 2023

Issue #, if available:
This PR fixed the issue #118

Users who are using the library in a VPC with no Internet connection are not able to use the Assume role feature as STS Regional End point doesn't work.

Description of changes:
This PR add an STS Endpoint configuration in the Credential Provider to enable the usage of region STS Endpoint.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Comment on lines 273 to 276
EndpointConfiguration endpointConfiguration =
new EndpointConfiguration(
String.format("sts.%s.amazonaws.com", stsRegion),
stsRegion);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR.
When you follow https://docs.aws.amazon.com/sdkref/latest/guide/feature-sts-regionalized-endpoints.html
and set

[default]
sts_regional_endpoints = regional

doesn't it pick it up by itself?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm running my job on KDA and I can't do such a setup on this service.

AWSSecurityTokenService stsClient = AWSSecurityTokenServiceClientBuilder.standard()
.withRegion(stsRegion)
.withEndpointConfiguration(endpointConfiguration)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to set the endpoint configuration? if the stsRegion is set to aws-global it should be using sts.amazonaws.com anyway.

regional – The SDK or tool always uses the AWS STS endpoint for the currently configured Region. For example, if the client is configured to use us-west-2, all calls to AWS STS are made to the Regional endpoint sts.us-west-2.amazonaws.com, instead of the global sts.amazonaws.com endpoint. To send a request to the global endpoint while this setting is enabled, you can set the Region to aws-global.

https://docs.aws.amazon.com/sdkref/latest/guide/feature-sts-regionalized-endpoints.html

Have you tested this out? In KDA you should be able to define an environment variable and override the REGION config.

My concern with manually setting endpointconfiguration is the following endpoint might not be valid for all aws regions and partitions in the future.

EndpointConfiguration(
                            String.format("sts.%s.amazonaws.com", stsRegion),
                            stsRegion);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I published a new commit to use region.getServiceEndpoint API instead of a string.

Copy link
Contributor

@plazma-prizma plazma-prizma Jul 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also try setting region as aws-global in KDA?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aws-global is not reachable for customer who are running KDA or MSK Connect in a private subnet. They have to use a regional endpoint for STS.

@plazma-prizma plazma-prizma merged commit 45be4a5 into aws:main Jul 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants